<template>
  <div class="loginForm">
    <form action="">
      <van-field v-model="phone" type="tel"/>
      <van-field v-model="password" type="password"/>
      <van-button round size="large" color="#7232dd" @click="login">登录</van-button>
    </form>
  </div>
</template>

<script>
  import http from '@/utils/index'
  import api from '@/utils/api'
  export default {
    data () {
      return {
        phone: 13883305345,
        password: ''
      }
    },
    onLoad () {
      console.log('login')
    },
    methods: {
      login () {
        let params = {
          phone: this.phone,
          password: this.password
        }
        http.request(api.phoneLogin, params, 'GET')
          .then((res) => {
            if (res.code === 200) {
              wx.setStorageSync('token', res.token)
              wx.setStorageSync('islogin', true)
              wx.navigateBack({
                delta: 1
              })
            }
          })
      }
    }
  }
</script>

<style scoped>
  .loginForm{
    width: 100%;
    height: 100%;
    background: #C62F2F;
  }
</style>
